<?php

class Hoa extends CI_Controller
{
	function them()
	{
		$data = array(
			'page'=>'themhoa',
			'dsdm'=>$this->mdanhmuchoa->danhsachdanhmucAdmin()
		);
		$this->load->view('admin/templateadmin', $data);
	}
	
	function xulythem()
	{
		$tenhoa = $this->input->post('tenhoa');
		$soluong = $this->input->post('soluong');
		$gia = $this->input->post('gia');
		$mota = $this->input->post('mota');
		
		// Thuc hien upload hinh anh
		$config['upload_path'] = './asset/upload/';
		$config['allowed_types'] = 'gif|jpg|png';
		$config['max_size']	= '1024';
		$config['encrypt_name']	= true;
		$this->load->library('upload', $config);
		$hinhanh = '';
		if($this->upload->do_upload('hinhanh'))
		{
			$df = array('upload_data' => $this->upload->data());
			$hinhanh = $df['upload_data']['file_name'];
		}
		$hienthi = $this->input->post('hienthi')=='true' ? 'true' : 'false';
		$madm = $this->input->post('madm');
		$this->mhoa->themhoa($tenhoa, $gia, $soluong, $hinhanh, $mota, $hienthi, $madm);
		redirect('admin/hoa/danhsach');		
	}
	
	function danhsach()
	{
		$data = array(
			'page'=>'danhsachhoa',
			'dsh'=>$this->mhoa->danhsachhoaAdmin()
		);	
		$this->load->view('admin/templateadmin', $data);
	}
	
	function xoahoa($mahoa)
	{
		$this->mhoa->xoahoa($mahoa);
		redirect('admin/hoa/danhsach');	
	}
	
	function thongtin($mahoa)
	{
		$data = array(
			'page'=>'thongtinhoa',
			'tth'=>$this->mhoa->thongtinhoa($mahoa)
		);
		$this->load->view('admin/templateadmin', $data);
	}
	
	
}

?>